A template in Trilium serves as a predefined structure for other notes, referred to as instance notes. Assigning a template to a note brings three main effects:
#isInheritable=false are inherited
by the instance notes, although only inheritable attributes are further
inherited by the children of the instance notes.A typical example would be a "Book" template note, which might include:
An instance note is a note related to a template note. This relationship means the instance note's content is initialized from the template, and all attributes from the template are inherited.
To create an instance note through the UI:
For the template to appear in the menu, the template note must have the #template label.
Do not confuse this with the ~template relation, which links
the instance note to the template note. If you use workspaces,
you can also mark templates with #workspaceTemplate to display
them only in the workspace.
Templates can also be added or changed after note creation by creating
a ~template relation pointing to the desired template note.
To specify a template for child notes, you can use a ~child:template relation
pointing to the appropriate template note. There is no limit to the depth
of the hierarchy — you can use ~child:child:template, ~child:child:child:template,
and so on.
A template can gather the notes created from it in one place, instead
of having them land wherever they happen to be created. To do so, add a ~template:newNoteDefaultParent relation
to the template note, pointing at the note that should hold the instances,
for example a Person template pointing to a People note.
Adding the relation several times places the new note in every target, as Cloning Notes. The relation can also be inherited (e.g. from a folder holding several templates), in which case a relation owned by the template itself replaces the inherited one. The default parent is only inherited from the template's ancestors in the tree: a template created from another template does not adopt that template's default parent.
The default parent is used whenever a note is created from the template through the Choose note type dialog:
@-completion in a Text noteCreating an instance note from the Note Tree context menu (Insert child note, Insert note after) still creates it at the chosen place.
Unlike the Note Inbox, which holds quickly captured notes until they are sorted, the default parent is meant as the instances' permanent location.
By default, newly created notes are Text notes.
If a parent note defines a child:template pointing to a template
of a different type (e.g. a Code note), the behavior depends on how the
new note is created:
Selecting a specific template from the creation menu always takes precedence
over child:template.
From a visual perspective, templates can define #iconClass and #cssClass attributes,
allowing all instance notes (e.g., books) to display a specific icon and
CSS style.
Explore the concept further in the Demo Notes, including examples like the Relation Map, Task Manager, and Day Notes.
Additionally, see Default Note Title for
creating title templates. Note templates and title templates can be combined
by creating a #titleTemplate for a template note.